package com.glorysoft.lipuxinpda.activity

import android.content.Intent
import android.os.Bundle
import com.glorysoft.lipuxinpda.R
import com.glorysoft.lipuxinpda.base.BaseActivity
import com.glorysoft.lipuxinpda.callback.StringCommonCallBack
import com.glorysoft.lipuxinpda.dialog.InputFragmentDialog
import com.pda.platform.ui.ui_pdaplatform.entity.FreeUI_AddViewEntity
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_ActivityManager
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_Utils

/**
 * FileName: DialogActivity
 * Author: XJH
 * Date: 2021/4/15 15:35
 * Description:
 * History:
 */
class DialogActivity : BaseActivity() {
    private var inputFragmentDialog: InputFragmentDialog? = null

    override fun getLayoutResId(): Int {
        return 0
    }

    override fun initView() {
//        val extra = intent.getStringExtra(FreeApi_StaticMembers.SHOW_PLUGIN_KEY)
        val extra = intent.getStringExtra("showPlugin")

        //切换用户
        if (extra == "SwitchingUsers") {
            FreeApi_ActivityManager.getActivityManager().finishAllActivity()
            startActivity(Intent(this@DialogActivity, LoginActivity::class.java))
            return
        }

        //退出
        if (extra == "Exit") {
            FreeApi_ActivityManager.getActivityManager().AppExit(this@DialogActivity)
            return
        }
        inputFragmentDialog = InputFragmentDialog()
        var lint = getString(R.string.scanDeviceBarCode)
        if (extra == "SupplementaryDataActivity" || extra == "QcActivity") {
            lint = "请扫描LOT条码"
        } else if (extra == "MoldReplaceActivity") {
            lint = "请扫描模具"
        } else if (extra == "DailyInspectionActivity") {
            lint = " 请扫描设备或LOT条码"
        }
        inputFragmentDialog?.setCallBackAndWhere(lint, object : StringCommonCallBack {
            override fun onCallback(str: String?) {
                val bundle = Bundle()
                bundle.putString("EQPID", str)
                when (extra) {
                    "BatchWorkBeginActivity" ->
                        FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, BatchWorkBeginActivity::class.java)
                    "BatchWorkEndActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, BatchWorkEndActivity::class.java)
                    "MaterialExchangeActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, MaterialExchangeActivity::class.java)
                    "DaycheckActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, DaycheckActivity::class.java)
                    "UnlockActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, UnlockActivity::class.java)
                    "EngineerModelActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, EngineerModelActivity::class.java)
                    "RealTimeActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, RealTimeActivity::class.java)
                    "DeviceStatusReplaceActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                    "LockmachineActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                    "SupplementaryDataActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                    "PmManagementActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                    "MoldCleaningActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                    "ActivationActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                    "MoldReplaceActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                    "DownRecipeActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                    "SharpenActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                    "QcActivity" -> FreeApi_Utils.skipWithExtraIntent("header", bundle, this@DialogActivity, LoginActivity::class.java)
                }
            }

            override fun onCallback(str: Int) {}
        }, "")
        inputFragmentDialog?.setCallBack {
            finish()
            FreeApi_ActivityManager.getActivityManager().finishActivity()
        }
        inputFragmentDialog?.show(supportFragmentManager, "URL_IP_DIALOG")
    }

    override fun initData() {

    }

    override fun getBaseEntity(): FreeUI_AddViewEntity? {
        return null
    }
}